@file:OptIn(ExperimentalUuidApi::class)

package com.harth.blemultiplatform.ble

import com.harth.blemultiplatform.ble.core.BondState
import com.harth.blemultiplatform.ble.core.ConnectionParameters
import com.harth.blemultiplatform.ble.core.ConnectionPriority
import com.harth.blemultiplatform.ble.core.PeripheralType
import com.harth.blemultiplatform.ble.core.Phy
import com.harth.blemultiplatform.ble.core.PhyInUse
import com.harth.blemultiplatform.ble.core.PhyOption
import com.harth.blemultiplatform.ble.core.WriteType
import kotlinx.coroutines.flow.StateFlow
import kotlin.uuid.ExperimentalUuidApi
import kotlin.uuid.Uuid

interface IPeripheral:AutoCloseable {
    val name:String?
    val address:String

    val bondState: StateFlow<BondState>

    val connectionParameters: StateFlow<ConnectionParameters?>

    val phy: StateFlow<PhyInUse?>

    val type: PeripheralType

    suspend fun readPhy(): PhyInUse

    suspend fun createBond()

    suspend fun removeBond()

    suspend fun requestConnectionPriority(priority: ConnectionPriority):ConnectionParameters

    suspend fun setPreferredPhy(
        txPhy: Phy,
        rxPhy: Phy = txPhy,
        phyOptions: PhyOption = PhyOption.NO_PREFERRED,
    ): PhyInUse

    fun maximumWriteValueLength(type: WriteType): Int

    fun services(uuids: List<Uuid> = emptyList()): StateFlow<List<IService>?>

    suspend fun readRssi(): Int

    suspend fun disconnect(): Boolean
}